import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)
export default new Vuex.Store({
    state:{
        code:0,
        userCode:0,
        orderCode:0,
        userName: ''
    },
    getters:{
        getState(state){
            return state.code
        },
        getUser(state){
            return state.userCode
        },
        getOrder(state){
            return state.orderCode
        },
        getUserName(state){
            return state.userName
        }
    },
    mutations:{
        updateCode(state,code){
            state.code=code
        },
        updateUserCode(state,userCode){
            state.userCode=userCode
        },
        updateOrderCode(state,orderCode){
            state.orderCode=orderCode
        },
        updateUserName(state,userName){
            state.userName=userName
        }
    },
    plugins: [createPersistedState({
        storage: window.cookie
    })]
})
